<template>
  <nav>
    <van-nav-bar class="navbar" title="keee tools" v-bind:border="false" />
  </nav>
  <main>
    <RouterView />
  </main>

  <van-floating-bubble
    icon="wap-home-o"
    @click="goHome"
    v-if="!isHome"
    v-model:offset="offset"
  />
</template>

<script setup>
import { RouterView } from "vue-router";
import { useRouter, useRoute } from "vue-router";
import { computed, onMounted } from "vue";
import { showToast } from "@/utils/toastHelper";
import { ref } from "vue";
import { getLeftPosition, getRightPosition } from "@/utils/bubblePosition";

// 使用右下角位置作为默认位置
const offset = ref(getRightPosition());

// 如果想用左下角位置，可以改为：
// const offset = ref(getLeftPosition());

const route = useRoute();
const router = useRouter();


function goHome() {
  router.push("/");
  showToast("已返回首页");
}
const isHome = computed(() => route.path === "/");
</script>

<style scoped>
main {
  margin-top: 4rem;
}
.navbar {
  --van-nav-bar-height: 90px;
  --van-nav-bar-title-font-size: 2rem;
}
</style>
